<?php
// Module Definition
$module['name'] = 'Server Monitoring';
$module['description'] = 'Monitors services and vital server statistics.';

switch($action) {
	case 'register':
		break;
	case 'unregister':
		break;
	case 'enable':
		// Ideally would cleardatafiles here - but need root privaledges
		$SQL = 'INSERT INTO crons(month, week, day, hour, minute, user, comment, fork, timeout, hook, createdby)
				VALUES("*", "*", "*", "*", "*", "", "Run service monitor.", 1, 0, "server:monitor:check", "monitor.mod.phps")';
		$res = mysql_query($SQL);
		$data = Array();
		return $res;
		break;
	case 'disable':
		// Ideally would cleardatafiles here - but need root privaledges
		$SQL = 'DELETE FROM crons WHERE createdby = "monitor.mod.phps"';
		$res = mysql_query($SQL);
		return $res;
		break;
	case 'hook':
		register_hook('server:monitor:check', 'monitor_check');
		register_hook('server:service:stop', 'monitor_check');
		register_hook('server:service:start', 'monitor_check');
		register_hook('server:service:restart', 'monitor_check');
		register_hook('web:menu', 'monitor_add_menu');
		register_hook('web:lang', 'monitor_add_lang');
		register_hook('web:personal:serverstatus', 'monitor_user');
		register_hook('web:domain:serverstatus', 'monitor_user');
		register_hook('web:reseller:serverstatus', 'monitor_serverinfo');
		register_hook('web:server:serverstatus', 'monitor_server');
		register_hook('web:server:serverinfo', 'monitor_serverinfo');
		register_hook('web:server:serverinfodetails', 'monitor_serverinfodetails');
		register_hook('web:server:serverresourcedetails', 'monitor_resource_usage');
		break;
}
?>